package coupon

import (
	"context"
	// "fmt"

	"mall/common/utils/pointy"
	"mall/service/backend/api/internal/svc"
	"mall/service/backend/api/internal/types"
	"mall/service/backend/common/i18n"

	// "github.com/sirupsen/logrus"
	"github.com/zeromicro/go-zero/core/logx"
)

type GetPredefinedListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGetPredefinedListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPredefinedListLogic {
	return &GetPredefinedListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetPredefinedListLogic) GetPredefinedList() (*types.PromotionPredefinedListResp, error) {
	formDefault := []*types.MetaInfo{
		{
			Key:   pointy.GetPointer("condition"),
			Value: pointy.GetPointer("1"),
		},
		{
			Key:   pointy.GetPointer("discountMode"),
			Value: pointy.GetPointer("1"),
		},
		{
			Key:   pointy.GetPointer("scopeType"),
			Value: pointy.GetPointer("0"),
		},
		{
			Key:   pointy.GetPointer("expireMode"),
			Value: pointy.GetPointer("1"),
		},
		{
			Key:   pointy.GetPointer("status"),
			Value: pointy.GetPointer("0"),
		},
	}

	statusList := []*types.MetaInfo{
		{
			Key:   pointy.GetPointer("pending"),
			Name:  pointy.GetPointer("待审核"),
			Slug:  pointy.GetPointer("pending"),
			Value: pointy.GetPointer("0"),
		},
		{
			Key:   pointy.GetPointer("common"),
			Name:  pointy.GetPointer("正常"),
			Slug:  pointy.GetPointer("common"),
			Value: pointy.GetPointer("1"),
		},
		{
			Key:   pointy.GetPointer("rejected"),
			Name:  pointy.GetPointer("禁用"),
			Slug:  pointy.GetPointer("rejected"),
			Value: pointy.GetPointer("2"),
		},
		{
			Key:   pointy.GetPointer("started"),
			Name:  pointy.GetPointer("已生效"),
			Slug:  pointy.GetPointer("started"),
			Value: pointy.GetPointer("10"),
		},
		{
			Key:   pointy.GetPointer("expired"),
			Name:  pointy.GetPointer("已过期"),
			Slug:  pointy.GetPointer("expired"),
			Value: pointy.GetPointer("20"),
		},
		{
			Key:   pointy.GetPointer("deleted"),
			Name:  pointy.GetPointer("回收站"),
			Slug:  pointy.GetPointer("deleted"),
			Value: pointy.GetPointer("3"),
		},
	}

	activityTypeList := []*types.MetaInfo{
		{
			Key:   pointy.GetPointer("spendAndSave"),
			Name:  pointy.GetPointer("满减活动"),
			Slug:  pointy.GetPointer("spendAndSave"),
			Value: pointy.GetPointer("1"),
		},
	}

	couponTypeList := []*types.MetaInfo{
		{
			Key:   pointy.GetPointer("receive"),
			Name:  pointy.GetPointer("可领取"),
			Slug:  pointy.GetPointer("receive"),
			Value: pointy.GetPointer("1"),
		},
		{
			Key:   pointy.GetPointer("exchange"),
			Name:  pointy.GetPointer("可兑换"),
			Slug:  pointy.GetPointer("exchange"),
			Value: pointy.GetPointer("2"),
		},
		{
			Key:   pointy.GetPointer("present"),
			Name:  pointy.GetPointer("可发放"),
			Slug:  pointy.GetPointer("present"),
			Value: pointy.GetPointer("4"),
		},
	}

	metaKeyList := []*types.MetaInfo{
		{
			Key:  pointy.GetPointer("title"),
			Name: pointy.GetPointer("标题"),
			Slug: pointy.GetPointer("title"),
		},
		{
			Key:  pointy.GetPointer("keywords"),
			Name: pointy.GetPointer("关键词"),
			Slug: pointy.GetPointer("keywords"),
		},
		{
			Key:  pointy.GetPointer("description"),
			Name: pointy.GetPointer("描述"),
			Slug: pointy.GetPointer("description"),
		},
	}

	return &types.PromotionPredefinedListResp{
		BaseDataInfo: types.BaseDataInfo{
			Success: true,
			Msg:     l.svcCtx.Trans.Trans(l.ctx, i18n.Success),
		},
		Data: types.PromotionPredefinedListInfo{
			FormDefault:      formDefault,
			StatusList:       statusList,
			MetaKeyList:      metaKeyList,
			ActivityTypeList: activityTypeList,
			CouponTypeList:   couponTypeList,
		},
	}, nil
}
